import unittest
import fibonacci


class MyTestCase(unittest.TestCase):
    def test_positive(self):
        def generate_fibonacci():
            pre = 0
            current = 1
            yield pre
            yield current
            while True:
                pre, current = current, pre + current
                yield current

        for i, f in enumerate(generate_fibonacci(), start=1):
            self.assertEqual(f, fibonacci.number_in_fibonacci(i))
            if i == 100:
                break

    def test_near_zero(self):
        fib = {-3: -3, -2: 2, -1: -1, 0: 1, 1: 0, 2: 1, 3: 1, 4: 2, 5: 3, 6: 5}
        for key in fib:
            self.assertEqual(fib[key], fibonacci.number_in_fibonacci(key))


if __name__ == '__main__':
    unittest.main()
